﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBUtlity;
using Models;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class UserInfoService
    {
        /// <summary>
        /// 根据用户名获取Email地址
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public UserInfo GetUserInfo(string userName)
        {
            string sql = "select UserName,Email,DisplayName,Email from UserInfoes";
            sql += " where UserName = @UserName";
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@UserName",userName)
            };
            SqlDataReader objReader = SQLHelper.GetReader(sql, param);
            UserInfo userInfo = null;
            if(objReader.Read())
            {
                userInfo = new UserInfo()
                {
                    UserName = objReader["UserName"].ToString(),
                    DisplayName = objReader["DisplayName"].ToString(),
                    Email = objReader["Email"].ToString()
                };
            }
            return userInfo;
        }
    }
}
